package echat.future.cn.echat.message.activity;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import java.util.ArrayList;
import java.util.List;

import echat.future.cn.echat.R;
import echat.future.cn.echat.message.MessageApi;
import echat.future.cn.echat.message.adapter.EbiAdapter;
import echat.future.cn.echat.message.bean.EbiBean;
import echat.future.cn.echat.my.utils.HttpUtilsRequst;
import echat.future.cn.echat.my.utils.UserHelper;
import lumingweihua.future.cn.baselibgxh.base.BaseActivity;

/**
 * 我的E币
 * Created by JX on 2018/8/12.
 */

public class EbiActivity extends BaseActivity {

    private RecyclerView rv;

    private EbiAdapter mAdapter;

    @Override
    protected void initView() {
        setContentView(R.layout.activity_ebi);

        findViewById(R.id.iv_back).setOnClickListener(this);

        rv = findViewById(R.id.ebi_rv);
        mAdapter = new EbiAdapter(R.layout.message_ebi_rv_item, new ArrayList<>());
        mAdapter.bindToRecyclerView(rv);
        rv.setLayoutManager(new LinearLayoutManager(this));
    }

    @Override
    protected void initData() {

        new HttpUtilsRequst<List<EbiBean>>(this, HttpUtilsRequst.retrofitClient.create(MessageApi.class)
                .ebi_get(UserHelper.getToken()))
                .setmOnRequstSuccessListener(new HttpUtilsRequst.OnRequstSuccessListener<List<EbiBean>>() {
                    @Override
                    public void onSuccss(List<EbiBean> ebiBeans) {
                        mAdapter.setNewData(ebiBeans);
                    }
                }).start();
    }

    @Override
    protected void processClick(View v) {
        switch (v.getId()) {
            case R.id.iv_back:
                finish();
                break;
        }
    }
}